//
//  MineAccountHeaderView.m
//  BakeCenter
//
//  Created by Barnett Wu on 15/9/21.
//  Copyright (c) 2015年 Baked. All rights reserved.
//

#import "MineAccountHeaderView.h"

@implementation MineAccountHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        UIImageView *imageView = [[UIImageView alloc] init];
        
        [self setUpCamberImage:imageView radius:50.0];

        UILabel *nameLabel = [[UILabel alloc] init];
        [self setUpNameLabel:nameLabel];
        
        [self trimViewFrame:imageView andNameLabel:nameLabel];
        
        UILabel *spaceLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 200,  kScreenWidth  , 10 * ( kScreenHeight / 375))];
        
        spaceLabel.backgroundColor = [UIColor clearColor];
        
        [self addSubview:spaceLabel];
       
    }
    return self;
}

//  图片圆角
- (void)setUpCamberImage:(UIImageView *)imageView radius:(float)radius
{
    imageView.backgroundColor = [UIColor yellowColor];
    imageView.layer.masksToBounds = YES;
    imageView.layer.borderWidth = 1.8;
    imageView.layer.backgroundColor = [[UIColor babyBlueColor] CGColor];
    imageView.layer.cornerRadius = radius;
    imageView.layer.borderColor = [[UIColor lightGrayColor] CGColor];
    
    [self addSubview:imageView];
}

//  姓名
- (void)setUpNameLabel:(UILabel *)nameLabel
{
    nameLabel.backgroundColor = [UIColor lightCreamColor];
    nameLabel.text = @"1234";
    nameLabel.textAlignment = NSTextAlignmentCenter;
    nameLabel.font = [UIFont boldSystemFontOfSize:14.0];
    [self addSubview:nameLabel];
}

- (void)trimViewFrame:(UIImageView *)imageView andNameLabel:(UILabel *)nameLabel
{
    int spaceHeight = 10;
    
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.top.mas_equalTo(@30);
        make.bottom.mas_equalTo(nameLabel.mas_top).offset(- spaceHeight);
        make.height.mas_equalTo(@100);
        make.width.mas_equalTo(@100);
    }];
    
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.top.mas_equalTo(imageView.mas_bottom).offset(spaceHeight);
        make.height.mas_equalTo(@30);
        make.width.mas_equalTo(@120);
    }];
}







@end
